//
// Created by benxb on 2021/11/11.
//

#ifndef BENXDB_FILEUTIL_H
#define BENXDB_FILEUTIL_H

#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
#endif

#include <sys/stat.h>
#include <cstdint>
#include <string>

namespace benxdb {

class FileUtil {
public:
    static int64_t GetFileSize(const std::string &file_name) {
        struct stat64 stat_buf{};
        int rc = stat64(file_name.c_str(), &stat_buf);
        return rc == 0 ? static_cast<int64_t>(stat_buf.st_size) : -1;
    }

};

}

#endif //BENXDB_FILEUTIL_H
